package com.example.aircraftwar.codes.aircraft;

import android.content.Context;

import com.example.aircraftwar.codes.basic.AbstractFlyingObject;
import com.example.aircraftwar.codes.bullet.BaseBullet;
import com.example.aircraftwar.codes.strategy.ShootStrategy;

import java.util.List;

public abstract class AbstractAircraft extends AbstractFlyingObject {

    protected int maxHp;
    protected int hp;
    private ShootStrategy shootStrategy;

    public AbstractAircraft(Context context, int locationX, int locationY, int speedX, int speedY, int hp, ShootStrategy shootStrategy) {
        super(context, locationX, locationY, speedX, speedY);
        this.hp = hp;
        this.maxHp = 2 * hp;
        this.shootStrategy = shootStrategy;
    }

    public void decreaseHp(int decrease){
        hp -= decrease;
        if(hp >= maxHp)
        {
            hp = maxHp;
        }
        if(hp <= 0){
            hp=0;
            vanish();
        }
    }

    public int getHp() {
        return hp;
    }

    public void setStrategy(ShootStrategy shootStrategy) {
        this.shootStrategy = shootStrategy;
    }

    public List<BaseBullet> shoot(){
        return shootStrategy.executeShootStrategy(context,this);
    };

}